class code2 {
    //将上题相同变为#即可
    //因为要进行两次，直接分装成函数
    public boolean backspaceCompare(String s, String t) {
        return toChange(s).equals(toChange(t));
    }
    public String toChange(String ss) {
        StringBuffer ret = new StringBuffer();
        char[] s = ss.toCharArray();
        for(char ch:s) {
            if(ret.length()>0 && ch=='#') ret.deleteCharAt(ret.length()-1);
                //注意#不能加入字符串
            else if(ch!='#') ret.append(ch);
        }
        return ret.toString();
    }
}